#include <iostream>
#include "msg1.h"
#include "msg2.h"


class Recevicer : public BaseHandle<Messgae1>
                , public BaseHandle<Messgae2>
{
public:
    Recevicer() { std::cout << "Recevicer()" << std::endl; }
    ~Recevicer() { std::cout << "~Recevicer()" << std::endl; }
    virtual bool handle(const Messgae1 *pMsg)
    {
        if(pMsg == nullptr)
            return false;
        std::cout << "SyncMessage ==> user: " << pMsg->user << ", passwd: " << pMsg->passwd << std::endl;
        return true;
    }
    virtual bool handle(const Messgae2 *pMsg)
    {
        if(pMsg == nullptr) {
            std::cout << "AsynMessgae ===> pMsg is nullptr......\n";
            return false;
        }
        std::cout << "AsynMessgae ==> type: " << pMsg->type << ", result: " << pMsg->result << std::endl;
        return true;
    }
};


int main()
{
    Recevicer recv;
    Messgae1 aMsg;
    aMsg.user = "lijiangjun";
    aMsg.passwd = "123456";
    aMsg.post();
    Messgae2 msg;
    msg.type = 0;
    msg.result = true;
    msg.send();
    
    std::this_thread::sleep_for(std::chrono::microseconds(150));
    return 0;
}